﻿using System;
using System.Web.WebPages;

namespace Mvc4Demo.App_Start
{
    public static class DisplayMode
    {
        public static void RegisterDisplayMode()
        {
            var iPhoneDisplay = new DefaultDisplayMode("iPhone")
                {
                    ContextCondition = (ctx => ctx.GetOverriddenUserAgent()
                                                       .IndexOf("iPhone", StringComparison.OrdinalIgnoreCase) >= 0)
                };


            var androidDisplay = new DefaultDisplayMode("android")
                {
                    ContextCondition = (ctx => ctx.GetOverriddenUserAgent()
                                                   .IndexOf("android", StringComparison.OrdinalIgnoreCase) >= 0)
                };


            DisplayModeProvider.Instance.Modes.Insert(0, androidDisplay);
            DisplayModeProvider.Instance.Modes.Insert(1, iPhoneDisplay);


        }
    }
}